text = """
111
222
333
"""
old_str = "222"
new_str = "555\n666"

# 字符串替换
new_text = text.replace(old_str, new_str)
print(new_text)

""" 
111
555
666
333
"""